<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require_once APPPATH.'models/user_model.php';

class Wb_user_model extends User_model {
    
    protected $TB_WB_USER = 'dc_wb_user';
    protected $WB_USER_COLS = array(
        'user_id', 
        'wb_uid', 
        'screen_name', 
        'auth_time'
    );

    public function __construct() {
        parent::__construct();
    }
    
    public function add_wb_user($wb_uid, $screen_name=null, $auth_time=null) {
        $email = null;
        $mobile = null;
        $auth_time = $auth_time or date('Y-m-d H:i:s', time());
        $user_id = $this->add_user($email, $mobile, $auth_time);
        $query = $this->db->query("INSERT INTO $this->TB_WB_USER 
            (`user_id`, `wb_uid`, `screen_name`, `auth_time`) VALUES
            ('$user_id', '$wb_uid', '$screen_name', '$auth_time')");
        return $user_id;
    }
    
    public function get_users_id_by_wb_uids($wb_uids) {}
    
    public function get_user_wb_uid($uid) {}
    
    public function get_wb_uids_of_users($uids) {}
    
    public function update_login_time($wb_uid, $time=null) {}

    public function get_user_id_by_wb_uid($wb_uid) {
        $query = $this->db->query("SELECT user_id FROM {$this->TB_WB_USER} 
            WHERE `wb_uid` = {$wb_uid} LIMIT 1");
        return $query->num_rows() ? current($query->row()) : false;
    }
    
}